// d3、2.2、Vuex中存储共享状态（是否显示，显示内容，显示类型/图标）
export default {
    namespaced: true,
    state: {
        isShowToast: false,
        toastType: "warning",
        toastMsg: "这是封装提示框组件默认的提示！",
    },
    mutations: {
        // d3、2.3、Vuex中增加修改数据的方法mutations
        chengIsShowToast(state, payload) {
            // console.log("执行了chengIsShowToast函数");
            state.isShowToast = payload.show
            if (payload.show) {
                state.toastType = payload.tType
                state.toastMsg = payload.tMsg
            }
        }
    },
    actions: {
        // d3、2.4、实现定时关闭 actions
        asyncShowToast({ commit }, payload) {
            // console.log("触发了asyncShowToast方法");
            commit("chengIsShowToast", payload)
            setTimeout(() => {
                commit("chengIsShowToast", payload.show = false)
            }, 2000)
        }
    }
}